<?php
function openConnection()
{
    $link = mysql_connect(DATABASE_HOST . ":" . DATABASE_PORT, DATABASE_USER, DATABASE_PASS);
    mysql_select_db(DATABASE_NAME, $link);
    return $link;
} 

function queryDatabase($query, $link)
{
    return mysql_query($query, $link);
}

function fetchResults($query)
{
    $result = array();
    while ($assoc = mysql_fetch_assoc($query))
    {
        $result[] = $assoc;
    }
    return $result;
}

function closeConnection($link)
{
    mysql_close($link);
} 
?>